Load in packages

Read in raw groilla data

# read in low test expect data exported from gorilla
setwd(here::here('SF_data', 'Gorilla_data_low'))

data=here::here('SF_data', 'Gorilla_data_low')  # path to data files

file_list=list.files(data, pattern=".csv") # list of data files
 
# read in all files
datasetlow <-
  do.call("rbind", lapply(file_list, FUN=function(files){
    
    for (i in 1:length(files)){ 
      if(file.exists(files[i])){
        message( "now processing:", files[i])
      }
    }
    fread(files, header=TRUE, sep=",", na.strings = "", fill=TRUE)})) #fread makes reading in files quick
#
library(lubridate)
# clean up data! Select data from after the pre-registation! 


low<-datasetlow %>% 
  janitor::clean_names(.) %>% 
  dplyr::mutate(date=as.Date(utc_date)) %>%
  dplyr::filter(date=="08/06/2020" |date=="09/06/2020" , zone_type=="response_button_text")

#response as character
low$response<-as.character(low$response)

#assign column to denot low test expect
low$testexpect<-"low"
# high test expect
setwd(here::here('SF_data', 'Gorilla_data_high'))

data=here::here('SF_data', 'Gorilla_data_high')  # path to data files

file_list=list.files(data, pattern=".csv") # list of data files
 
# read in all files
highdata <-
  do.call("rbind", lapply(file_list, FUN=function(files){
    
    for (i in 1:length(files)){ 
      if(file.exists(files[i])){
        message( "now processing:", files[i])
      }
    }
    fread(files, header=TRUE, sep=",", na.strings = "", fill=TRUE)})) #fread makes reading in files quick
#
library(lubridate)
# a batch of Ss we run before preregistration that should not be included in the analysis
high <-highdata %>% 
  janitor::clean_names(.) %>% 
  dplyr::mutate(date=as.Date(utc_date)) %>%
  dplyr::filter(date=="08/06/2020" | date=="0009/07/2020" |date=="0010/07/2020" | date=="09/06/2020", zone_type=="response_button_text")

#response as character
high$response<-as.character(high$response)

# assign column to denot high test expect
high$testexpect<-"high"
# bind low and high datasets
high_low<-rbind(high, low)

Recognition memory

Calculate d-prime

#response as character
#calculate hit rate and far and compute dprime and other measures
ex4=high_low %>% dplyr::mutate(condition1= dplyr::case_when( 
  condition == "SF" ~ "Sans Forgetica", 
  condition =="normal" ~  "Arial", 
), isold= dplyr::case_when (
  old_new== "old" ~ 1, 
  old_new== "new" ~ 0), 
sayold=dplyr::case_when( 
  response=="old"~ 1, 
  response=="new" ~ 0, 
  ))


#classic SDT
sdt <- ex4 %>% 
  dplyr::mutate(type = "hit",
         type = ifelse(isold==1 & sayold==0, "miss", type),
         type = ifelse(isold==0 & sayold==0, "cr", type),  # Correct rejection
         type = ifelse(isold==0 & sayold==1, "fa", type))  # False alarm
sdt <- sdt %>% 
  dplyr::group_by(participant_private_id, type, condition1, testexpect) %>% 
  dplyr::summarise(count = n()) %>% 
  tidyr::spread(type, count)  # Format data to one row per person

sdt <- sdt %>% 
  dplyr::group_by(participant_private_id, condition1, testexpect)%>%
  dplyr::mutate(hr = hit / (hit+miss),
         fa = fa / (fa+cr)) %>%
  dplyr::mutate(hr=case_when(
    is.na(hr) ~ 0.99,
    TRUE ~ hr), 
    fa=case_when(
      is.na(fa)  ~ 0.01,
    TRUE ~ fa),
     zhr=qnorm(hr), 
     zfa=qnorm(fa), 
    dprime = zhr-zfa) %>%
  ungroup()

Plot

Raincloud plots (Allen et al., 2019) depicting raw data (dots), box plots, and half violin kernel desntiy plots, with mean (red dot). Proportion of “old” responses as a function of Test Expectancy for Experiment 1.

Raincloud plots (Allen et al., 2019) depicting raw data (dots), box plots, and half violin kernel desntiy plots, with mean (red dot). Proportion of “old” responses as a function of Test Expectancy for Experiment 1.

#set up raincloud params
# fig for dprime

highlowaov=sdt  %>% select(participant_private_id, condition1, testexpect, dprime) %>%
  mutate(testexpect=ifelse(testexpect=="low", "Low Test Expectancy", "High Test Expectancy"))
#plot

fig1 <- ggplot(highlowaov,aes(x=condition1,y=dprime,fill=condition1))+ facet_grid(~testexpect) + 
  geom_flat_violin(position = position_nudge(x = .2, y = 0), alpha = .4,adjust=4)+
  geom_point(position=position_jitter(width = .15),size = 1, alpha = 0.2) + 
  geom_boxplot(aes(x = condition1, y = dprime),outlier.shape = NA,
               alpha = 0.3, width = .1, colour = "BLACK") +
  stat_summary(fun=mean, geom="point", colour="darkred", size=3) + 
  theme_cowplot() +
  scale_colour_brewer(palette = "Dark2")+
  scale_fill_brewer(palette = "Dark2") +
  labs(y = "Sensitivity(d')", x = "Typeface") + theme(legend.position = "none")

fig1

ggsave("dprimefig1.png", width=8, height=4)

Analysis

#ANOVA


a1 <- aov_ez("participant_private_id", "dprime", highlowaov, 
             between = c("testexpect"), within=c("condition1")) # mixed

summary(a1)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                        Sum Sq num Df Error SS den Df  F value    Pr(>F)    
## (Intercept)           296.652      1  166.184    229 408.7834 < 2.2e-16 ***
## testexpect              2.980      1  166.184    229   4.1058  0.043896 *  
## condition1              1.818      1   38.786    229  10.7344  0.001215 ** 
## testexpect:condition1   0.735      1   38.786    229   4.3369  0.038405 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#kable(summary(a1))

JOLs

Read in JOL data

# get JOls from raw data

high
jol_high<- highdata %>% 
  mutate(testexpect="high")
low
jol_low<-datasetlow %>%
  mutate(testexpect="low")
jol_high_low <- rbind(jol_high, jol_low)

#bind high and low
jols<-jol_high_low %>% janitor::clean_names(.) %>% dplyr::mutate(date=as.Date(utc_date)) %>%  dplyr::filter(date=="08/06/2020" | date=="0009/07/2020"|date=="0010/07/2020" | date=="09/06/2020",  zone_type=="response_slider_endValue" | zone_type=="response_text_entry")


jols$response<-as.numeric(jols$response)


jols1<- jols %>%
  dplyr::select(participant_private_id, response, testexpect) %>%
  dplyr::mutate(cond=rep(1:2, 231), font=ifelse(cond==1, "SF", "A")) %>%
  tidyr::drop_na() %>% 
  dplyr::mutate(testexpect=ifelse(testexpect=="low", "Low Test Expectancy", "High Test Expectancy"), font=ifelse(font=="A", "Arial", "Sans Forgetica"))

Plot JOls

# plot JOLs

figjol <- ggplot(jols1,aes(x=font,y=response,fill=font))+ facet_grid(~testexpect) + 
  geom_flat_violin(position = position_nudge(x = .2, y = 0), alpha = .4,adjust=4)+
  geom_point(position=position_jitter(width = .15),size = 1, alpha = 0.2) + 
  geom_boxplot(aes(x = font, y = response),outlier.shape = NA,
               alpha = 0.3, width = .1, colour = "BLACK") +
    stat_summary(fun=mean, geom="point", colour="darkred", size=5)+
  theme_cowplot() +
  scale_colour_brewer(palette = "Dark2")+
  scale_fill_brewer(palette = "Dark2") +
  labs(y = "Judgements of Learning", x = "Typeface") + theme(legend.position = "none")

ggsave("figjol.png", width=8, height=4, dpi=300)

figjol

#6.67

Analysis

#anova JOLs
a1 <- aov_ez("participant_private_id", "response", jols1, 
             between = c("testexpect"), within=c("font")) # mixed

summary(a1)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                  Sum Sq num Df Error SS den Df  F value    Pr(>F)    
## (Intercept)     1575566      1   403702    221 862.5179 < 2.2e-16 ***
## testexpect        29254      1   403702    221  16.0145 8.579e-05 ***
## font               1803      1    14729    221  27.0520 4.509e-07 ***
## testexpect:font       9      1    14729    221   0.1334    0.7152    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

RTs

Read in RT data

#raw gorilla data and extract RTs

datasetlow$testexpt<-"low"
highdata$testexpt<-"high"

rt_high_low <- rbind(datasetlow, highdata)

rt<-rt_high_low %>% janitor::clean_names(.) %>% mutate(date=as.Date(utc_date)) %>%  dplyr::filter(date=="08/06/2020" | date=="0009/07/2020"|date=="0010/07/2020" | date=="09/06/2020", zone_type=="continue_button", display=="study") 

# get RT and make numeric (Gorilla does not do this)
rt$reaction_time<-as.numeric(rt$reaction_time)

rt1<- rt %>% 
  dplyr::group_by(participant_private_id, condition, testexpt) %>% 
  dplyr::select(participant_private_id, condition, testexpt, reaction_time) %>%
  dplyr::mutate(sdabove = mean(reaction_time, na.rm=TRUE) +  2.5*sd(reaction_time, na.rm=TRUE)) %>%
    dplyr::filter(reaction_time > 150, reaction_time < sdabove) %>%
  dplyr::summarise(mean_rt= mean(log(reaction_time))) %>%
   mutate(testexpt=ifelse(testexpt=="low", "Low Test Expectancy", "High Test Expectancy"), font=ifelse(condition=="normal", "Arial", "Sans Forgetica")) %>%
  select(-condition)

Plot RT data

#plot fig

figrt <- ggplot(rt1,aes(x=font,y=mean_rt,fill=condition))+ facet_grid(~testexpt) + 
  geom_flat_violin(position = position_nudge(x = .2, y = 0), alpha = .4,adjust=4)+
  geom_point(position=position_jitter(width = .15),size = 1, alpha = 0.2) + 
  geom_boxplot(aes(x = font, y = mean_rt),outlier.shape = NA,
               alpha = 0.3, width = .1, colour = "BLACK") +
    stat_summary(fun=mean, geom="point", colour="darkred", size=5)+
  theme_cowplot() +
  scale_colour_brewer(palette = "Dark2")+
  scale_fill_brewer(palette = "Dark2") +
  labs(y = "log(Study Times/ms)", x = "Typeface") + theme(legend.position = "none")


ggsave("figrt.png", width=8, height=4, dpi=300)

figrt

#write.csv(rt2, file="rt_high_low.csv")

#ttestBF(x=rt2$normal, y=rt

Analysis

#anova RTs

a1 <- aov_ez("participant_private_id", "mean_rt", rt1, 
             between = c("testexpt"), within=c("condition")) # 

summary(a1)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                     Sum Sq num Df Error SS den Df    F value    Pr(>F)    
## (Intercept)        20706.2      1  168.431    229 28152.2648 < 2.2e-16 ***
## testexpt               1.1      1  168.431    229     1.5354    0.2166    
## condition              0.3      1    1.797    229    33.0251 2.884e-08 ***
## testexpt:condition     0.0      1    1.797    229     1.1292    0.2891    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#kable(summary(a1))